package cn.gxufe.reliable.message.api.controller;

/**
 * @author yingjie.rong
 **/
import cn.gxufe.reliable.message.api.consumer.TryServiceConsumer;
import cn.gxufe.reliable.message.common.ResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/reliable/message")
public class ForConsumerMessageController {

    private static final Logger logger = LoggerFactory.getLogger(ForConsumerMessageController.class);


    @Autowired
    private TryServiceConsumer tryServiceConsumer;

    /**
     * 作为下游服务的时候，可靠消息确认，是否处理成功了
     * @param messageId
     * @param key
     * @param header
     * @return
     */
    @PostMapping("/tryFinishOrCancel")
    public ResultVo tryFinish(@RequestParam("messageId") Long messageId,
                              @RequestParam("key") String key,
                              @RequestParam("header") String header){
        logger.info("tryFinishOrCancel : messageId = {} , key = {} , header = {} ",messageId,key,header);
        return tryServiceConsumer.finishOrCancel(messageId,key,header);
    }

}
